{% extends "shuup/admin/base.jinja" %}
{% from "shuup/admin/macros/general.jinja" import content_with_sidebar %}

{% block body_class %}shuup-details{% endblock %}
{% block content %}
    {% call content_with_sidebar(content_id="category_form") %}
        <form method="post" id="category_form" novalidate>
            {% csrf_token %}
            {% for form_def in form.form_defs.values() %}
                {% include form_def.template_name with context %}
            {% endfor %}
        </form>
    {% endcall %}
{% endblock %}
{% block extra_js %}
    <script>
        function copyVisibilityToProducts(event, $el){
            event.preventDefault();
            $el.attr("disabled", true);
            $.ajax({
                type: "POST",
                url: "{{ url('shuup_admin:category.copy_visibility', pk=category.pk) if category.pk else ''}}",
                data: {csrfmiddlewaretoken: window.ShuupAdminConfig.csrf},
                success: function(msg) {
                    window.Messages.enqueue({tags: "info", text: msg.message});
                },
                error: function(response) {
                    var message = _("An unexpected error has occurred.");
                    if(response.responseJSON && response.responseJSON.message){
                        message = response.responseJSON.message;
                    }
                    window.Messages.enqueue({tags: "error", text: message});
                },
                complete: function(){
                    $el.attr("disabled", false);
                }
            });
        }
        (function() {
            window.tourConfig = {
                tourComplete: ("{{ tour_complete }}" == "True" ? true : false),
                tourKey: "{{ tour_key }}",
                url: ShuupAdminConfig.browserUrls.tour,
                initialSteps: [{
                    title: "{% trans %}Add a new product category{% endtrans %}",
                    icon: "{{ static('shuup_admin/img/category.png') }}",
                    classes: "has-icon",
                    text: [
                        "{% trans %}You are adding a new product category. When people search your store, they can find your product under the category you choose for it, like the aisle signs at the supermarket.{% endtrans %}",
                        "{% trans %}You can add a name, description, picture or anything you want to make it stand out.{% endtrans %}"
                    ]
                }]
            };
        })();
    </script>
{% endblock %}
